package com.example.demo.service.impl;

import com.example.demo.entity.User;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @Name
 * @Author 村头老杨头
 * @Date 2022/9/27 7:58
 * @Description
 **/
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User getUserByID(Integer uid) {
        return userMapper.selectByPrimaryKey(uid);
    }

    @Override
    public List<User> getUsers() {
        return userMapper.selectAll();
    }

    @Override
    public int addUser(User user) {
        user.setCreatetime(LocalDateTime.now());
        return userMapper.insertSelective(user);
    }
}
